package com.jlnk.dagger.views;

import android.util.Log;

import com.jlnk.dagger.R;
import com.jlnk.dagger.application.MyApplication;
import com.jlnk.dagger.base.BaseActivity;
import com.jlnk.dagger.database.CourseDBHelper;
import com.jlnk.dagger.database.DBHelper;
import com.jlnk.dagger.entity.Course;
import com.jlnk.dagger.entity.Student;
import com.jlnk.dagger.utils.SpUtils;


import java.util.List;

import jakarta.inject.Inject;

public class InfoActivity extends BaseActivity {
    @Inject
    public Student mStudent;
    @Inject
    public DBHelper mDBHelper;
    @Inject
    public CourseDBHelper mCourseDBHelper;
    @Override
    public int getLayoutId() {
        return R.layout.activity_info;
    }

    @Override
    public void init() {
        /*DaggerAllComponent
                .builder()
                .studentModule(new StudentModule())
                .dBModule(new DBModule(this))
                .build()
                .injectInfoActivity(this);*/
        ((MyApplication)getApplication()).getAllComponent().injectInfoActivity(this);
        Log.d("asdf", "Info mStudent === " + mStudent.hashCode());
        List<Student> list = mDBHelper.selectAllStudent();
        int size = list.size();
        Log.d("asdf", "Info mDBHelper === " + mDBHelper.hashCode());
        mStudent = mDBHelper.selectAllStudent().get(size - 1);
        //Log.d("asdf", "Info mStudent === " + mStudent.hashCode());
        Log.d("asdf", mStudent.toString());

        List<Course> courses = mCourseDBHelper.selectAllCourse();
        for (Course course : courses) {
            Log.d("InfoActivity", "课程名称: " + course.getCourseName());
        }
        SpUtils spUtils = ((MyApplication) getApplication()).getSpUtils();
        String courseName = spUtils.getString("course_name");
        Log.d("InfoActivity", "存储的课程名称: " + courseName);
    }
}
